<template>
  <div class="nav-menu">
    <div
      v-for="(item, index) in menuList"
      :key="index"
      class="dis-flex menu-item"
      @click="menuClick(item, index)"
    >
      <svg-icon class="menu-icon" :icon-class="getIconName(item)" />
      {{ item.label }}
    </div>
  </div>
</template>

<script>
export default {
  props: {
    menuList: {
      type: Array,
      required: true
    },
    callback: {
      type: Function,
      required: true
    },
    fatherIndex: {
      type: Number,
      required: true
    }
  },
  data() {
    return {};
  },
  methods: {
    menuClick(item) {
      this.callback(item, this.fatherIndex);
    },
    getIconName(item) {
      const isFile = item.isFile;
      if (!isFile) {
        if (item.projectId || item.tmpProjectIcon) {
          return 'project';
        }
        return 'folderopen';
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.nav-menu {
  background: #fafafa;
  border: 1px solid #a7a7a7;
}
.menu-item {
  height: 28px;
  line-height: 28px;
  padding: 0 5px;
  border: 1px solid transparent;

  &:hover {
    border: 1px solid #0099ff;
  }
}
.menu-icon {
  width: 16px;
  height: 16px;
  margin: 6px 6px 6px 0px;
  background-repeat: no-repeat;
}
</style>
